#ifndef __INTR_H__
#define __INTR_H__

#include <types.h>

#include <sys/event.h>
#include <sys/unistd.h>

struct irq {
    int irqn;			/* vector number */
    int (*isr)(void *);	        /* routine if in kernel */
    void *data; 		/* data for ISR/IST */
    uint32_t flags;

    int prio;
    int ist_msg;		/* num of msg for IST */
    int ist_req;                /* if msg not zero the IST in user space! */
    thread_t *ist;		/* ptr to Interrupt service thread (NULL if user proc!) */
    uint32_t cnt;               /* the num of irqs */
    event_t *ist_event;         /* event for IST */
};

#define IRQ_NONE	0x00
#define	IRQ_ISR		0x01
#define	IRQ_HALF	0x02

/* irq flags */
#define ISR_USER        0x02
#define ISR_SYS         0x01
#define ISR_NONE        0x00

void irq_run(int);
void irq_init(void);

/* from low level code */
extern int splhi(void);
extern void splx(int);

#endif	/* __INTR_H__ */
